require 'active_record'

#run this command regulary (every month) with 'rake clean', to remove unneeded (unconfirmed) reservations
desc "remove reservations which were not confirmed"
task :clean => :environment do |t|
  unconfirmed_reservations = Reservation.find(:all, :conditions => ['state != ?', 'paid'])
  puts "Destroy #{unconfirmed_reservations.size} reservations which were not confirmed"
  unconfirmed_reservations.each { |res| res.destroy}
end